package com.example.order.Controller;

import com.example.order.model.OrderInfo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @RequestMapping("/createOrder1")
    public String createOrder1(){
        String orderId= UUID.randomUUID().toString();
        rabbitTemplate.convertAndSend("","order.create","下单成功,订单ID:"+orderId);
        return "下单成功";
    }
    @RequestMapping("/createOrder2")
    public String createOrder2(){
        String orderId= UUID.randomUUID().toString();
        OrderInfo orderInfo=new OrderInfo(orderId,"Maybe");
        rabbitTemplate.convertAndSend("","order.create",orderInfo);
        return "下单成功";
    }

}
